#include "FiveWin.ch"
#include "Visual.ch"
#include "xbrowse.ch"

memvar oIDE


CLASS TOptionsComp
	
	DATA  cFile 			
	DATA  nType				

	DATA  bDefault		INIT {}


  DATA  aOptions,;          // compiler options
				aDescription ,;			// compiler options description
				aValue,;						// compiler options values
				aActivated,;				// compiler options activated
				aEntry,;						// entry ini file for compiler options
				aLibH,;							// Libraries Habour
				aLibXH,;						// Libraries xHabour
				aHDefaultLib,;			// Default Lib for Habour
				axHDefaultLib,;			// Default Lib for xHabour
				aHDefault  ,;				// default Path (bin, include, libs, flags ) Harbour
				axHDefault ,;				// default Path (bin, include, libs, flags ) xHarbour
				aLnkDefault,;				// default values for Linker section (linker filename, linker bulid flags
				;										// Borland Lib, Resource Compiler, Resoruce type, Compiler C, compiler C Flags
				aLnkLibs,;					// Linker Lib		
				aDefaultLnkLib,;		// Default Linker libs
				aFwhDefault,;				// Default path FWH (lib, include )
				aOtherLibs,;				  // Other libs
				aPrjDefault					// Project default path and values ( output, source, resource obj,
														// windows style, compiler )
	
	DATA  cHPath,;						// Harbour Bin Path
				cHCHPath,;					// Harbour include path
				cHLibPath,;					// Harbour libs path
				cHMoreOpt,;					// Harbour compiler aditional Options
				cHOptHide,;					// Harbour compiler option from aOptions
				cXHPath,;						// xHarbour Bin Path
				cXHCHPath,;					// xHarbour include path
				cXHLibPath,;				// xHarbour libs path
				cXHMoreOpt,;				// xHarbour compiler aditional Options
				cXHOptHide,;				// xHarbour compiler option from aOptions
				cLibFW,;						// FWH libs path
				cCHFW,;							// FWH include path
				cLnkName ,;					// Linker filename
				cLnkFlags	,;				// Linker builds flags
				cLnkLibs ,;					// Linker Libs Path
				cResCompiler ,;			// Resource compiler
				cCompilerC,;				// Compiler C
				cCFlag,;						// Compiler C Flags
				cPrjOutput,;				// Project output path
				cPrjSource,;				// Project Source code path
				cPrjRes,;						// Project Resource path
				cPrjObj,;							// Project OBJ path
				cPrjMain						// Project Main Folder 
				
	DATA  lWndStyle						// Windows manifest
							
	DATA 	nResType,;					// Resource type ( RC, RES, DLL, NONE )
				nCompiler						// Project comiler ( harbour, xharbour )
				
				
	METHOD new( cFile, nType ) CONSTRUCTOR

	METHOD AddRemoveLib( aLibs, cLibs )
	
	METHOD CompilerIni(  ) 
	METHOD CompilerSave(  )
	
	METHOD DefaultAll() INLINE ( ::DefaultValue(), ;
															 ::DefaultActivated(), ;
															 ::DefaultHOption(),;
															 ::DefaultXHOption(),;
															 ::DefaultLnkOption(),;
															 ::DefaultPrj() )
	METHOD DefaultValue()
	METHOD DefaultActivated()
	METHOD DefaultHOption()
	METHOD DefaultXHOption()
	METHOD DefaultLnkOption()
	METHOD DefaultFWH()
	METHOD DefaultPrj()

	METHOD Option()	
	
	METHOD GetValueDefault( nOpc, x )

	ENDCLASS
	
	METHOD new( cFile, nType ) CLASS TOptionsComp
	
	DEFAULT cFile := "Visual.ini",;
					nType := MAIN
	
		::cFile := cFile
		::nType := nType
	
		::aHDefault  := {}
		::axHDefault := {}
	
		::cLnkName 		:= space( 128 )
		::cLnkFlags		:= space( 128 )
		::cLnkLibs		:= space( 128 )
		::cResCompiler:= space( 128 )
		::cCompilerC  := space( 128 )
		::cCFlag			:= space( 128 )
		
		
		::cPrjOutput	:= space( 128 )
		::cPrjSource	:= space( 128 )
		::cPrjRes			:= space( 128 )
		::cPrjObj			:= space( 128 )

		
		::cHOptHide		:= ""
		::cXHOptHide	:= ""
		
		::nResType		:= RESTYPE_RC
		
		::nCompiler := HARBOUR
		

	
		::aOptions 			:= { 	"/a","/b","/build","/credit",;
									 				"/d","/es",;
									 				"/g","/gc",;
									 				"/go","/gw","/gh","/gj",;
									 				"/i","/k","/l","/m",;
									 				"/n","/o","/p","/q",;
									 				"/q0","/s","/u",;
									 				"/v","/w","/x",;
									 				"/z" }
/*
		::aOptions 			:= { 	"/a","/b","/build","/credit",;
									 				"/d<id>[=val>]","/es[<level>]",;
									 				"/g<type>","/gc[<type>]",;
									 				"/go","/gw","/gh","/gj",;
									 				"/i<path>","/k","/l","/m",;
									 				"/n<type>","/o<path>","/p","/q",;
									 				"/q0","/s","/u[<file>]",;
									 				"/v","/w[<level>]","/x[<prefix>]",;
									 				"/z" }
*/
									 
		::aDescription := {		"automatic memvar declaration",;
													"debug info",;
													"display detailed version info",;
													"display credits",;
													"#define ID",;
													"set exit severity",;
													"output type generated is <type>",;
													"output type: C source (.c) (default)",;
													"output type: Platform dependant object module",;
													"output type: Windows/DOS OBJ32 (.obj)",;
													"output type: Harbour Portable Object (.hrb)",;
													"output type: Java source (.java)",;
													"#include file search path",;
													"compilation mode",;
													"suppress line number information",;
													"compiler module only",;
													"no implicit starting procedure (default)",;
													"object file drive and/or path",;
													"generate pre-processed output (.ppo) file",;
													"quiet",;
													"quiet and don't display program header",;
													"syntax check only",;
													"use command def set in <file> (or none)",;
													"variables are assumed M->",;
													"set warning level number (0..3, default 1)",;
													"set symbol init function name prefix (for .c only)",;
													"suppress shortcutting (.and. & .or.)" }

		::aValue 			:= array( len( ::aOptions ) )
		::aActivated 	:= array( len( ::aOptions ) )
		::aEntry 			:= array( len( ::aOptions ) )


		::aEntry[ OPC_MEMVAR ]				:= "Memvar"
		::aEntry[ OPC_DEBUG	 ]				:= "Debug"
		::aEntry[ OPC_BUILD  ]				:= "Build"
		::aEntry[ OPC_CREDIT ]				:= "Credit"
		::aEntry[ OPC_DEFINE ]				:= "Define"
		::aEntry[ OPC_SEVERITY ]			:= "Severity"
		::aEntry[ OPC_OUTPUTTYPEGEN ] := "OutPutTypeGen"
		::aEntry[ OPC_OUTPUTTYPE ]		:= "OutPutType"
		::aEntry[ OPC_PDOM ]					:= "PDOM"
		::aEntry[ OPC_OJB32 ]					:= "Obj32"
		::aEntry[ OPC_HPO ]					  := "HPO"
		::aEntry[ OPC_JAVA ]				  := "Java"
		::aEntry[ OPC_INCLUDE ]			  := "Include"
		::aEntry[ OPC_MODE ]				  := "Mode"
		::aEntry[ OPC_NOLINES ]			  := "NoLines"
		::aEntry[ OPC_ONEMODULE ]		  := "OneModule"
		::aEntry[ OPC_NOIMPLICIT ]	  := "NoImplicit"
		::aEntry[ OPC_OBJECTFILE ]	  := "ObjectFile"
		::aEntry[ OPC_PPO ]					  := "PPO"
		::aEntry[ OPC_QUIET ]				  := "Quiet"
		::aEntry[ OPC_QUIETNOT ]		  := "QuietNot"
		::aEntry[ OPC_SINTAXONLY ]	  := "SintaxOnly"
		::aEntry[ OPC_COMMANDDEF ]	  := "CommandDef"
		::aEntry[ OPC_VALIABLEM ]		  := "VariableM"
		::aEntry[ OPC_WARNINGS ]		  := "Warnings"
		::aEntry[ OPC_SYMBOL ]			  := "Symbol"
		::aEntry[ OPC_SUPPRESSSHOT ]  := "SuppressShot"									
		
		::aFwhDefault := { padR( "c:\fwh\lib", 128 ),;				//FWH/lib folder
  									 	 padR( "c:\fwh\include", 128 ) }		//FWH/include folder


		::aHDefault := { padR( "c:\harbour\bin", 128 ) ,;			//harbour/bin
										 padR( "c:\harbour\include", 128 ) ,;	//harbour/include
										 padR( "c:\harbour\lib", 128 ) ,;			//harbour/lib
										 space( 128 ) }																				//harbour Flags
										 
		::aHDefaultLib := {"hbrtl.lib",;
												"hbvm.lib",;
												"gtgui.lib",;
												"hblang.lib",;
												"hbmacro.lib",;
												"hbrdd.lib",;
												"rddntx.lib",;
												"rddcdx.lib",;
												"rddfpt.lib",;
												"hbsix.lib",;
												"hbdebug.lib",;
												"hbcommon.lib",;
												"hbpp.lib",;
												"hbcpage.lib",;
												"hbw32.lib"}

		::aXHDefaultLib := {"rtl.lib",;
												"vm.lib",;
												"gtgui.lib",;
												"lang.lib",;
												"macro.lib",;
												"rdd.lib",;
												"dbfntx.lib",;
												"dbfcdx.lib",;
												"dbffpt.lib",;
												"hbsix.lib",;
												"debug.lib",;
												"common.lib",;
												"pp.lib",;
												"pcrepos.lib" }
												
		::aDefaultLnkLib := {"cw32.lib",;
												 "import32.lib",;
												 "psdk\odbc32.lib",;
												 "psdk\msimg32.lib",;
												 "psdk\nddeapi.lib",;
												 "psdk\iphlpapi.lib",;
												 "psdk\rasapi32.lib" }
										

		::axHDefault := { padR( "c:\xharbour\bin", 128 )  ,;			//xharbour/bin
										  padR( "c:\xharbour\include", 128 ) ,;	//xharbour/include
											padR( "c:\xharbour\lib", 128 ) ,;			//xharbour/lib
											space( 128 ) }																				//xharbour Flags
			
		::aLnkDefault := { padR( "c:\bcc55\bin\ilink32.exe", 128 ),;		// linker name
											 padR( "-Gn -aa -Tpe -s", 128 ),;											// linker bulid flags
											 padR( "c:\bcc55\lib", 128 ),;								// Borland Lib
											 padR( "c:\bcc55\bin\brc32.exe", 128 ),;			// Resoure Compiler
											 RESTYPE_RC,;																					// Resoure Type
											 padR( "c:\bcc55\bin\bcc32.exe", 128 ),;			// Compiler C
											 padR( "-O2 -c -M -Ic:\borland\bcc55\include", 128 ) }// Compiler C Flags

		::aPrjDefault := { padR( CurDrive()+":\"+curdir(), 128 ),;	//output Folder
											 padR( CurDrive()+":\"+curdir(), 128 ),;	//source Folder
											 padR( CurDrive()+":\"+curdir(), 128 ),;	//resource folder
											 padR( CurDrive()+":\"+curdir(), 128 ),;	//obj folder
											 .t.,;																		//Windows Style
											 HARBOUR,;																//Compiler
										 	 padR( CurDrive()+":\"+curdir(), 128 ) } //main folder																	

		::aOtherLibs := {}											


	return self
	
	METHOD DefaultValue() CLASS TOptionsComp

		::aValue[ OPC_MEMVAR ]				:= ""
		::aValue[ OPC_DEBUG	 ]				:= ""
		::aValue[ OPC_BUILD  ]				:= ""
		::aValue[ OPC_CREDIT ]				:= ""
		::aValue[ OPC_DEFINE ]				:= space( 128 )
		::aValue[ OPC_SEVERITY ]			:= "2"
		::aValue[ OPC_OUTPUTTYPEGEN ] := space( 1 )
		::aValue[ OPC_OUTPUTTYPE ]		:= "1"
		::aValue[ OPC_PDOM ]					:= ""
		::aValue[ OPC_OJB32 ]					:= ""
		::aValue[ OPC_HPO ]					  := ""
		::aValue[ OPC_JAVA ]				  := ""
		::aValue[ OPC_INCLUDE ]			  := space( 128 )
		::aValue[ OPC_MODE ]				  := space( 30 )
		::aValue[ OPC_NOLINES ]			  := ""
		::aValue[ OPC_ONEMODULE ]		  := ""
		::aValue[ OPC_NOIMPLICIT ]	  := "0"
		::aValue[ OPC_OBJECTFILE ]	  := space( 128 )
		::aValue[ OPC_PPO ]					  := ""
		::aValue[ OPC_QUIET ]				  := ""
		::aValue[ OPC_QUIETNOT ]		  := ""
		::aValue[ OPC_SINTAXONLY ]	  := ""
		::aValue[ OPC_COMMANDDEF ]	  := space( 128 )
		::aValue[ OPC_VALIABLEM ]		  := ""
		::aValue[ OPC_WARNINGS ]		  := "0"
		::aValue[ OPC_SYMBOL ]			  := ""
		::aValue[ OPC_SUPPRESSSHOT ]  := ""
		
		::DefaultFWH()
		
return self
													
METHOD DefaultActivated() CLASS TOptionsComp													
													
		::aActivated[ OPC_MEMVAR ]				:= .f.
		::aActivated[ OPC_DEBUG	 ]				:= .f.
		::aActivated[ OPC_BUILD  ]				:= .f.
		::aActivated[ OPC_CREDIT ]				:= .f.
		::aActivated[ OPC_DEFINE ]				:= .f.
		::aActivated[ OPC_SEVERITY ]			:= .f.
		::aActivated[ OPC_OUTPUTTYPEGEN ] := .f.
		::aActivated[ OPC_OUTPUTTYPE ]		:= .f.
		::aActivated[ OPC_PDOM ]					:= .f.
		::aActivated[ OPC_OJB32 ]					:= .f.
		::aActivated[ OPC_HPO ]					  := .f.
		::aActivated[ OPC_JAVA ]				  := .f.
		::aActivated[ OPC_INCLUDE ]			  := .f.
		::aActivated[ OPC_MODE ]				  := .f.
		::aActivated[ OPC_NOLINES ]			  := .f.
		::aActivated[ OPC_ONEMODULE ]		  := .t.
		::aActivated[ OPC_NOIMPLICIT ]	  := .t.
		::aActivated[ OPC_OBJECTFILE ]	  := .f.
		::aActivated[ OPC_PPO ]					  := .f.
		::aActivated[ OPC_QUIET ]				  := .f.
		::aActivated[ OPC_QUIETNOT ]		  := .f.
		::aActivated[ OPC_SINTAXONLY ]	  := .f.
		::aActivated[ OPC_COMMANDDEF ]	  := .f.
		::aActivated[ OPC_VALIABLEM ]		  := .f.
		::aActivated[ OPC_WARNINGS ]		  := .t.
		::aActivated[ OPC_SYMBOL ]			  := .f.
		::aActivated[ OPC_SUPPRESSSHOT ]  := .f.
		

return self

METHOD GetValueDefault( nOpc, x )
local uValue

	DO CASE 
		CASE nOpc == OPC_VALUE
			uValue := ::aValue[ x ]			
			
		CASE nOpc == OPC_ACTIVATED
			uValue := ::aActivated[ x ]
			
		CASE nOpc == OPC_HARBOUR
			uValue := ::aHDefault[ x ]

		CASE nOpc == OPC_XHARBOUR
			uValue := ::aXHDefault[ x ]
			
		CASE nOpc == OPC_LINKER
			uValue := ::aLnkDefault[ x ]
			
		CASE nOpc == OPC_FWH
			uValue := ::aFwhDefault[ x ]
			
		CASE nOpc == OPC_PRJ
			uValue := ::aPrjDefault[ x ]
			
	ENDCASE 

return( uValue )
			

METHOD AddRemoveLib( aLibs, cLibs ) CLASS TOptionsComp
	local nAt	
	local nLen := len( aLibs )
	
	nAt := AScan( aLibs, cLibs )
	IF nAt > 0
		#ifdef __XHARBOUR__
			ADel( aLibs, nAt, .t. )
		#else
			ADel( aLibs, nAt )
			ASize( aLibs, nLen - 1 )
		#endif
	ELSE 
		aadd( aLibs, cLibs )
	ENDIF
	
return nil

METHOD DefaultHOption CLASS TOptionsComp
		
		::aLibH			:= {}
		::cHPath  	:= ::GetValueDefault( OPC_HARBOUR, 1 )
		::cHCHPath	:= ::GetValueDefault( OPC_HARBOUR, 2 )
		::cHLibPath	:= ::GetValueDefault( OPC_HARBOUR, 3 )
		::cHMoreOpt := ::GetValueDefault( OPC_HARBOUR, 4 )

RETURN self


METHOD DefaultXHOption CLASS TOptionsComp
		::aLibXH		:= {}
		::cXHPath  	:= ::GetValueDefault( OPC_XHARBOUR, 1 )
		::cXHCHPath	:= ::GetValueDefault( OPC_XHARBOUR, 2 )
		::cXHLibPath:= ::GetValueDefault( OPC_XHARBOUR, 3 )
		::cXHMoreOpt := ::GetValueDefault( OPC_XHARBOUR, 4 )

RETURN self

METHOD DefaultLnkOption CLASS TOptionsComp

		::cLnkName 		:= ::GetValueDefault( OPC_LINKER, 1 )
		::cLnkFlags		:= ::GetValueDefault( OPC_LINKER, 2 )
		::cLnkLibs		:= ::GetValueDefault( OPC_LINKER, 3 )
		::cResCompiler:= ::GetValueDefault( OPC_LINKER, 4 )
		::nResType		:= ::GetValueDefault( OPC_LINKER, 5 )
		::cCompilerC	:= ::GetValueDefault( OPC_LINKER, 6 )
		::cCFlag			:= ::GetValueDefault( OPC_LINKER, 7 )
		::aLnkLibs		:= {}

RETURN self

METHOD DefaultFWH CLASS TOptionsComp

		::cLibFW 	:= ::GetValueDefault( OPC_FWH, 1 )
		::cCHFW		:= ::GetValueDefault( OPC_FWH, 2 )

RETURN self


METHOD DefaultPrj CLASS TOptionsComp

		::cPrjOutput	:= ::GetValueDefault( OPC_PRJ, 1 )
		::cPrjSource	:= ::GetValueDefault( OPC_PRJ, 2 )
		::cPrjRes			:= ::GetValueDefault( OPC_PRJ, 3 )
		::cPrjObj			:= ::GetValueDefault( OPC_PRJ, 4 )
		::lWndStyle		:= ::GetValueDefault( OPC_PRJ, 5 )
		::nCompiler		:= ::GetValueDefault( OPC_PRJ, 6 )
		::cPrjMain		:= ::GetValueDefault( OPC_PRJ, 7 )
		::aOtherLibs  := {}
//		? 		::cPrjOutput,	::cPrjSource,::cPrjRes,::cPrjObj,::lWndStyle,::nCompiler,::cPrjMain		:= ::GetValueDefault( OPC_PRJ, 7 )

RETURN self



METHOD CompilerIni(  ) CLASS TOptionsComp
   local oIni
   local n
   local cEntry, cTemp := "", cFile
   local lDefault
   
		aadd( ::bDefault , { {||::GetValueDefault( OPC_FWH, 1 )}, 			{|| oIde:oGeneralOpt:cLibFW } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_FWH, 2 )}, 			{|| oIde:oGeneralOpt:cCHFW } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_ACTIVATED, n )}, {|| oIde:oGeneralOpt:aActivated[ n ]} } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_VALUE, n )}, 		{|| oIde:oGeneralOpt:aValue[ n ] } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_HARBOUR, 1 )},		{|| oIde:oGeneralOpt:cHPath} } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_HARBOUR, 2 )}, 	{|| oIde:oGeneralOpt:cHCHPath} } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_HARBOUR, 3 )}, 	{|| oIde:oGeneralOpt:cHLibPath } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_HARBOUR, 4 )}, 	{|| oIde:oGeneralOpt:cHMoreOpt } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_XHARBOUR, 1 )}, 	{|| oIde:oGeneralOpt:cXHPath} } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_XHARBOUR, 2 )}, 	{|| oIde:oGeneralOpt:cXHCHPath} } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_XHARBOUR, 3 )},	{|| oIde:oGeneralOpt:cXHLibPath} } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_XHARBOUR, 4 )},	{|| oIde:oGeneralOpt:cXHMoreOpt } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_LINKER, 1 )},		{|| oIde:oGeneralOpt:cLnkName} } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_LINKER, 2 )},		{|| oIde:oGeneralOpt:cLnkFlags} } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_LINKER, 3 )}, 		{|| oIde:oGeneralOpt:cLnkLibs} } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_LINKER, 4 )},		{|| oIde:oGeneralOpt:cResCompiler} } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_LINKER, 5 )},		{|| oIde:oGeneralOpt:nResType }} )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_LINKER, 6 )},		{|| oIde:oGeneralOpt:cCompilerC} } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_LINKER, 7 )},		{|| oIde:oGeneralOpt:cCFlag } } )
		aadd( ::bDefault , { {||""},		{|| "" } } )
		aadd( ::bDefault , { {||""},		{|| "" } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_PRJ, 1 )},		{|| oIde:oGeneralOpt:cPrjOutput } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_PRJ, 2 )},		{|| oIde:oGeneralOpt:cPrjSource } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_PRJ, 3 )},		{|| oIde:oGeneralOpt:cPrjRes } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_PRJ, 4 )},		{|| oIde:oGeneralOpt:cPrjObj } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_PRJ, 5 )},		{|| oIde:oGeneralOpt:lWndStyle } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_PRJ, 6 )},		{|| oIde:oGeneralOpt:nCompiler } } )
		aadd( ::bDefault , { {||::GetValueDefault( OPC_PRJ, 7 )},		{|| oIde:oGeneralOpt:cPrjMain } } )

	if ::nType == PROJECT
	  ::aActivated := AClone( oIde:oGeneralOpt:aActivated )
		::aValue		 := AClone( oIde:oGeneralOpt:aValue )
		::aOtherLibs := {}
		::aLibH			 := {}
		::aLibXH		 := {}
		::aLnkLibs	 := {}
		cFile := ::cFile
		/*
		if oIde:lNew
			cFile := trim( oIde:oGeneralOpt:cPrjMain ) + "\" + ::cFile
		else
			cFile := ::cFile//trim( oIde:oProject:oProjectOpt:cPrjMain ) + "\" + ::cFile
		endif
		*/

	ELSE
		cFile := curdirx()+::cFile
	ENDIF

	IF !file( cFile ) 
		lDefault := .t.
	ELSE
		lDefault := .f.
	ENDIF
	
	INI oIni FILENAME cFile

		GET ::cLibFW SECTION "FiveWin" ENTRY "libfwh" DEFAULT eval( ::bDefault[ 1 ][ ::nType ] ) of oIni
		GET ::cCHFW  SECTION "FiveWin" ENTRY "chfwh"  DEFAULT eval( ::bDefault[ 2 ][ ::nType ] ) of oIni
		
		for n = 1 to len( ::aOptions )
			cEntry := "l" + ::aEntry[ n ]
			GET ::aActivated[ n ] SECTION "Compiler" 	ENTRY cEntry 				DEFAULT  eval( ::bDefault[ 3 ][ ::nType ] ) of oIni
			GET ::aValue[ n ] 		SECTION "Compiler" 	ENTRY ::aEntry[ n ] DEFAULT  eval( ::bDefault[ 4 ][ ::nType ] ) of oIni
		next
		
		GET ::cHPath 		SECTION "Harbour" ENTRY "Path" 			DEFAULT eval( ::bDefault[ 5 ][ ::nType ] ) OF oIni
		GET ::cHCHPath 	SECTION "Harbour" ENTRY "CHPath" 		DEFAULT eval( ::bDefault[ 6 ][ ::nType ] ) OF oIni
		GET ::cHLibPath SECTION "Harbour" ENTRY "LibHPath" 	DEFAULT eval( ::bDefault[ 7 ][ ::nType ] ) OF oIni
		GET ::cHMoreOpt SECTION "Harbour" ENTRY "HMoreOpt" 	DEFAULT eval( ::bDefault[ 8 ][ ::nType ] ) OF oIni
		GET ::cHOptHide SECTION "Harbour" ENTRY "HOptHide" 	DEFAULT eval( ::bDefault[ 20 ][ ::nType ] ) OF oIni

		n = 1
		while ! Empty( cEntry := oIni:Get( "Libs Harbour", "Libs"+strzero( n++,2 ) ) )
			aadd( ::aLibH, cEntry )
		end

		GET ::cXHPath 		SECTION "xHarbour" ENTRY "xPath" 			DEFAULT eval( ::bDefault[ 9 ][ ::nType ] ) OF oIni
		GET ::cXHCHPath 	SECTION "xHarbour" ENTRY "xCHPath" 		DEFAULT eval( ::bDefault[ 10 ][ ::nType ] ) OF oIni
		GET ::cXHLibPath  SECTION "xHarbour" ENTRY "xLibHPath" 	DEFAULT eval( ::bDefault[ 11 ][ ::nType ] ) OF oIni
		GET ::cXHMoreOpt  SECTION "xHarbour" ENTRY "xHMoreOpt" 	DEFAULT eval( ::bDefault[ 12 ][ ::nType ] ) OF oIni
		GET ::cXHOptHide 	SECTION "xHarbour" ENTRY "xHOptHide" 	DEFAULT eval( ::bDefault[ 21 ][ ::nType ] ) OF oIni

		n = 1
		while ! Empty( cEntry := oIni:Get( "Libs xHarbour", "Libs"+strzero( n++,2 ) ) )
			aadd( ::aLibXH, cEntry )
		end


		GET ::cLnkName 			SECTION "linker" 	ENTRY "lnkname" 		DEFAULT eval( ::bDefault[ 13 ][ ::nType ] ) OF oIni
		GET ::cLnkFlags 		SECTION "linker" 	ENTRY "lnkflags" 		DEFAULT eval( ::bDefault[ 14 ][ ::nType ] ) OF oIni
		GET ::cLnkLibs  		SECTION "linker" 	ENTRY "lnklibs" 		DEFAULT eval( ::bDefault[ 15 ][ ::nType ] ) OF oIni
		GET ::cResCompiler  SECTION "linker"  ENTRY "rescompiler" DEFAULT eval( ::bDefault[ 16 ][ ::nType ] ) OF oIni
		GET ::nResType	  	SECTION "linker"  ENTRY "restype" 		DEFAULT eval( ::bDefault[ 17 ][ ::nType ] ) OF oIni
		GET ::cCompilerC  	SECTION "linker"  ENTRY "CompilerC" 	DEFAULT eval( ::bDefault[ 18 ][ ::nType ] ) OF oIni
		GET ::cCFlag	  		SECTION "linker"  ENTRY "cFlag" 			DEFAULT eval( ::bDefault[ 19 ][ ::nType ] ) OF oIni

		GET ::cPrjOutput		SECTION "Project"	ENTRY "Output"			DEFAULT eval( ::bDefault[ 22 ][ ::nType ] ) OF oIni
		GET ::cPrjSource		SECTION "Project"	ENTRY "Source"			DEFAULT eval( ::bDefault[ 23 ][ ::nType ] ) OF oIni
		GET ::cPrjRes				SECTION "Project"	ENTRY "Resource"		DEFAULT eval( ::bDefault[ 24 ][ ::nType ] ) OF oIni
		GET ::cPrjObj				SECTION "Project"	ENTRY "Obj"					DEFAULT eval( ::bDefault[ 25 ][ ::nType ] ) OF oIni
		GET ::lWndStyle			SECTION "Project"	ENTRY "Style"				DEFAULT eval( ::bDefault[ 26 ][ ::nType ] ) OF oIni
		GET ::nCompiler			SECTION "Project"	ENTRY "Compiler"		DEFAULT eval( ::bDefault[ 27 ][ ::nType ] ) OF oIni
		GET ::cPrjMain			SECTION "Project"	ENTRY "Main"				DEFAULT eval( ::bDefault[ 28 ][ ::nType ] ) OF oIni
	
		n = 1
		while ! Empty( cEntry := oIni:Get( "OtherLibs", "Libs"+strzero( n++,2 ) ) )
			aadd( ::aOtherLibs, cEntry )
		end

		n = 1
		while ! Empty( cEntry := oIni:Get( "Libs Linker", "Libs"+strzero( n++,2 ) ) )
			aadd( ::aLnkLibs, cEntry )
		end
			
		::cLibFW    := padR( ::cLibFW, 128 )
		::cCHFW			:= padR( ::cCHFW, 128 )	
		::cHPath 		:= padR( ::cHPath, 128 )
		::cHCHPath 	:= padR( ::cHCHPath, 128 )
		::CHLibPath := padR( ::CHLibPath, 128 )
		::cHMoreOpt := padR( ::cHMoreOpt, 128 )
		
		::cxHPath 		:= padR( ::cxHPath, 128 )
		::cxHCHPath 	:= padR( ::cxHCHPath, 128 )
		::cxHLibPath 	:= padR( ::cxHLibPath, 128 )
		::cxHMoreOpt 	:= padR( ::cxHMoreOpt, 128 )

		::cLnkName 		:= padR( ::cLnkName, 128 )
		::cLnkFlags		:= padR( ::cLnkFlags, 128 )
		::cLnkLibs		:= padR( ::cLnkLibs, 128 )
		::cResCompiler:= padR( ::cResCompiler, 128 )

		::cPrjOutput  := padR( ::cPrjOutput, 128 )
		::cPrjSource	:= padR( ::cPrjSource, 128 )
		::cPrjRes			:= padR( ::cPrjRes, 128 )
		::cPrjMain		:= padR( ::cPrjMain, 128 )
		::cPrjObj			:= padR( ::cPrjObj, 128 )

		//::nResType		:= VAL( ::nResType )


  ENDINI

 	aeval( ::aOptions, {| cVal, n | if( ::aActivated[ n ], cTemp += cVal + ::aValue[ n ] + " ",) } )
 	 		::cHOptHide   := cTemp
	 		::cXHOptHide  := cTemp
  
  if lDefault
  	if ::nType == MAIN
	 		::aLibH 			:= ::aHDefaultLib
	   	::aLibXH 			:= ::axHDefaultLib
	   	::aLnkLibs 		:= ::aDefaultLnkLib
	   	::aOtherLibs	:= {}
	   	::CompilerSave()
   else
	 		::aLibH 			:= AClone( oIde:oGeneralOpt:aLibH )
	   	::aLibXH 			:= AClone( oIde:oGeneralOpt:aLibXH )
	   	::aLnkLibs 		:= AClone( oIde:oGeneralOpt:aLnkLibs )
	   	::aOtherLibs 	:= AClone( oIde:oGeneralOpt:aOtherLibs )
 	 		::cHOptHide   := oIde:oGeneralOpt:cHOptHide 
	 		::cXHOptHide  := oIde:oGeneralOpt:cXHOptHide
	   	::CompilerSave( )
	   endif
  endif
  

return nil													

METHOD CompilerSave( ) CLASS TOptionsComp
   local oIni
   local n, nLen
   local cEntry, cTemp := "", cFile
   local lDefault
   

	aeval( ::aOptions, {| cVal, n | if( ::aActivated[ n ], cTemp += cVal + ::aValue[ n ] + " ",) } )
	::cHOptHide   := cTemp
	::cXHOptHide  := cTemp
	
	IF ::nType == PROJECT
		cFile := ::cFile
	ELSE
		cFile := curdirx()+::cFile
	ENDIF
	
	INI oIni FILENAME cFile
		
		SET SECTION "FiveWin" ENTRY "libfwh" OF oIni TO LOWER( ::cLibFW )
		SET SECTION "FiveWin" ENTRY "chfwh"  OF oIni TO LOWER( ::cCHFW )
	
		for n = 1 to len( ::aOptions )
			cEntry := "l" + ::aEntry[ n ]
			SET SECTION "Compiler" ENTRY cEntry        OF oIni TO ::aActivated[ n ]
			SET SECTION "Compiler" ENTRY ::aEntry[ n ] OF oIni TO ::aValue[ n ]
		next
		
		SET SECTION "Harbour" ENTRY "Path" 			OF oIni TO LOWER( ::cHPath )
		SET SECTION "Harbour" ENTRY "CHPath" 		OF oIni TO LOWER( ::cHCHPath )
		SET SECTION "Harbour" ENTRY "LibHPath" 	OF oIni TO LOWER( ::cHLibPath )
		SET SECTION "Harbour" ENTRY "HMoreOpt" 	OF oIni TO ::cHMoreOpt
		SET SECTION "Harbour" ENTRY "HOptHide" 	OF oIni TO ::cHOptHide

		n = 1
		for n = 1 to len( ::aLibH )
			cEntry := "Libs"+strzero( n,2 )
			SET SECTION "Libs Harbour" ENTRY cEntry OF oIni TO LOWER( ::aLibH[ n ] )
		next

		SET SECTION "xHarbour" ENTRY "xPath" 			OF oIni TO LOWER( ::cXHPath )
		SET SECTION "xHarbour" ENTRY "xCHPath" 		OF oIni TO LOWER( ::cXHCHPath )
		SET SECTION "xHarbour" ENTRY "xLibHPath" 	OF oIni TO LOWER( ::cXHLibPath )
		SET SECTION "xHarbour" ENTRY "xHMoreOpt" 	OF oIni TO ::cXHMoreOpt
		SET SECTION "xHarbour" ENTRY "xHOptHide" 	OF oIni TO ::cxHOptHide		

		for n = 1 to len( ::aLibXH )
			cEntry := "Libs"+strzero( n,2 )
			SET SECTION "Libs xHarbour" ENTRY cEntry OF oIni TO LOWER( ::aLibXH[ n ] )
		next
		
		SET SECTION "linker" ENTRY "lnkname" 			OF oIni TO LOWER( ::cLnkName )
		SET SECTION "linker" ENTRY "lnkflags" 		OF oIni TO ::cLnkFlags
		SET SECTION "linker" ENTRY "lnklibs" 			OF oIni TO LOWER( ::cLnkLibs )
		SET SECTION "linker" ENTRY "rescompiler" 	OF oIni TO LOWER( ::cResCompiler )
		SET SECTION "linker" ENTRY "restype" 			OF oIni TO ::nResType
		SET SECTION "linker" ENTRY "CompilerC" 		OF oIni TO LOWER( ::cCompilerC )
		SET SECTION "linker" ENTRY "cFlag" 				OF oIni TO ::cCFlag

		for n = 1 to len( ::aLnkLibs )
			cEntry := "Libs"+strzero( n,2 )
			SET SECTION "Libs Linker" ENTRY cEntry OF oIni TO LOWER( ::aLnkLibs[ n ] )
		next

		SET SECTION "Project"	ENTRY "Output"			OF oIni TO ::cPrjOutput		
		SET SECTION "Project"	ENTRY "Source"			OF oIni TO ::cPrjSource		
		SET SECTION "Project"	ENTRY "Resource"		OF oIni TO ::cPrjRes				
		SET SECTION "Project"	ENTRY "Obj"					OF oIni TO ::cPrjObj				
		SET SECTION "Project"	ENTRY "Style"				OF oIni TO ::lWndStyle			
		SET SECTION "Project"	ENTRY "Compiler"		OF oIni TO ::nCompiler
		SET SECTION "Project"	ENTRY "Main"				OF oIni TO ::cPrjMain

		for n = 1 to len( ::aOtherLibs )
			cEntry := "Libs"+strzero( n,2 )
			SET SECTION "OtherLibs" ENTRY cEntry OF oIni TO LOWER( ::aOtherLibs[ n ] )
		next

		
	ENDINI

return nil													

//-------------------------------------------------------------
METHOD Option(  ) CLASS TOptionsComp

   local oDlg, oFld, oRadio, oRadio2, oFromProc, oChkBox
   local oBrw, oBrwHLib, oBrwXHLib, oBrwLnk, oBtn, oBrwOther
 	 local aHLibs, aXHLibs, aOptionCompiler, aLnkLibs, aOtherLibs
 	 local cTemp := "",;
 	 			 cTitle
 	 local aGet := array( 22 ) //TOTAL GETS 
 	 local n
 	 
 	 if ::nType == MAIN
 	 	oFromProc := oIde:oGeneralOpt
 	 else
 	 	oFromProc := oIde:oProject:oProjectOpt
 	 endif
 	 
 	 if oIde:lNew
		 ::DefaultAll()
		 ::CompilerIni()
	 endif

 	 aOptionCompiler = GetOptions( Self )

	 for n = 1 to len( ::aOptions )
	 	if ::aActivated[ n ]
	 		cTemp += ::aOptions[ n ] + ::aValue[ n ] + " "
	 	endif
	 next

	::cHOptHide 	:= padR( cTemp, 128 )
	::cXHOptHide  := padR( cTemp, 128 )
  
  IF ::nType == MAIN
  	cTitle := "General Option Setup"
  ELSE 
  	cTitle := "Project Setup"
  ENDIF
   
   DEFINE DIALOG oDlg RESOURCE "Option" TITLE cTitle TRANSPARENT

		REDEFINE FOLDER oFld ID 110 OF oDlg ;
    ITEMS   "Project Setup", "Compiler","Harbour","xHarbour","Linker" ;
    DIALOGS "prjsetup","generaloptions","harxhar", "harxhar", "linkeropt"

		//----------------------------------------------------
		// GENERAL OPTIONS COMPILER 
		//----------------------------------------------------
		
	 REDEFINE GROUP ID ID_GROUP_ONE		OF oFld:aDialogs[ FLD_COMPILEROPTION ] 	
	 REDEFINE SAY ID ID_SAYPATHFW 		OF oFld:aDialogs[ FLD_COMPILEROPTION ] 	
	 REDEFINE SAY ID ID_SAYINCLUDEFW 	OF oFld:aDialogs[ FLD_COMPILEROPTION ] 	
		
	 REDEFINE GET aGet[ GET_CHFW ] VAR ::cCHFW ID	ID_GETPATHFW OF oFld:aDialogs[ FLD_COMPILEROPTION ] 	;
	 	BITMAP "folder" ACTION( IF( !empty( cTemp := cGetDir("Select include path FWH") ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ),),;
	 													eval( aGet[ GET_CHFW ]:bValid ) ) ;
	 COLOR if ( !IsDirectory(::cCHFW ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !IsDirectory(::cCHFW ), ;
	 						aGet[ GET_CHFW ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 						aGet[ GET_CHFW ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ) , .t. )  ;
	 UPDATE
	 
	 REDEFINE GET aGet[ GET_LIBFW ] VAR ::cLibFW 	ID  ID_GETINCLUDEFW OF oFld:aDialogs[ FLD_COMPILEROPTION ] 	;
	 	BITMAP "folder" ACTION( IF( !empty( cTemp := cGetDir("Select libraries path FWH") ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ),),;
	 												 eval( aGet[ GET_LIBFW ]:bValid ) ) ;
	 COLOR if ( !IsDirectory(::cLibFW ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !IsDirectory(::cLibFW ), ;
	 						aGet[ GET_LIBFW ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 						aGet[ GET_LIBFW ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ), .t. ) ;
	 UPDATE
		
   REDEFINE XBROWSE oBrw ;
      FIELDS oBrw:aRow:lActivated, ;
      			 oBrw:aRow:cOptions, ;
      			 oBrw:aRow:cDescription, ;
      			 {|x| oBrw:aRow:value(x) } ;
      HEADERS 'Select', 'Option',"Description","Value" ;
      COLSIZES 40, 63,247,180 ;
      ARRAY aOptionCompiler OF oFld:aDialogs[ FLD_COMPILEROPTION ] ;      
      ON CHANGE SetEditType( oBrw )

	 oBrw:bClrStd          = { || If( ( oBrw:nArrayAt % 2 ) == 0, { CLR_BLACK, RGB( 224, 236, 255 ) }, { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
   oBrw:bClrSel          = { || If( ( oBrw:nArrayAt % 2 ) == 0, { CLR_BLACK, RGB( 224, 236, 255 ) }, { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
   oBrw:nMarqueeStyle    = MARQSTYLE_HIGHLROW
   oBrw:nColDividerStyle = LINESTYLE_DARKGRAY
	 oBrw:bKeyDown				 = {|nKey| if ( nKey == VK_DELETE, ;
	 													(::aValue[ oBrw:nArrayAt ] := "", oBrw:refresh() ) , ) }

   
   oBrw:aColS[ COL_VALUE ]:bLDClickData := ;
   		{ || if ( AScan( { OPC_DEFINE,;
   											 OPC_INCLUDE,;
   											 OPC_OBJECTFILE,;
   											 OPC_COMMANDDEF }, {| uVal | uVal == oBrw:nArrayAt } ) > 0,;
   						( ::aValue[ oBrw:nArrayAt ] := TextDialog( ::aValue[ oBrw:nArrayAt ] ), ;
   							oBrw:refresh() ),;
   						oBrw:aCols[ COL_VALUE ]:edit() ) }
   																
   oBrw:lRecordSelector = .F.


	 oBrw:aCols[ COL_SELECT ]:SetCheck( {"on","off"},{|o,x,n| cTemp := "", oBrw:aRow:lActivated := x ,;
	  aeval( oBrw:aArrayData, ;
	 				{| oRow | if( oRow:lActivated, ;
	 										  cTemp += oRow:cOptions +;
	 										           oRow:uValue + " ",)} ), ;
 	 ::cHOptHide   := cTemp,;
	 ::cXHOptHide  := cTemp } )
	 																						
	 																																
   oBrw:aCols[ COL_SELECT ]:bStrData := {||nil}
   oBrw:aCols[ COL_SELECT ]:nDataBmpAlign := AL_CENTER


   oBrw:CreateFromResource(400) 
   oBrw:SetColor( 0, RGB( 224, 236, 255 ) )
   
   //---------------------------------------------------
   // HARBOUR OPTIONS
   //---------------------------------------------------
   REDEFINE SAY ID ID_SAYCOMPILERPATH OF oFld:aDialogs[ FLD_HARBOUROPTION ]
   REDEFINE SAY ID ID_SAYINCLUDEPATH 	OF oFld:aDialogs[ FLD_HARBOUROPTION ]
   REDEFINE SAY ID ID_SAYLIBSPATH 		OF oFld:aDialogs[ FLD_HARBOUROPTION ]
   REDEFINE SAY ID ID_SAYMOREOPTION 	OF oFld:aDialogs[ FLD_HARBOUROPTION ]
   
   REDEFINE GET aGet[ GET_HPATH ] VAR ::cHPath 		ID ID_GETCOMPILERPATH OF oFld:aDialogs[ FLD_HARBOUROPTION ] ;
   	BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetDir( "Select Harbour Complier Path", ::Value() ) ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ),),;
	 													eval( aGet[ GET_HPATH ]:bValid ) ) ;
	 COLOR if ( !IsDirectory( ::cHPath ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !IsDirectory( ::cHPath ), ;
	 						aGet[ GET_HPATH ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 						aGet[ GET_HPATH ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ) , .t. );  
	 UPDATE
   
   REDEFINE GET aGet[ GET_HCHPATH ] VAR ::cHCHPath 	ID ID_GETINCLUDEPATH 	OF oFld:aDialogs[ FLD_HARBOUROPTION ] ;
   	BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetDir( "Select Harbour Include Path", ::Value() ) ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ),),;
	 													eval( aGet[ GET_HCHPATH ]:bValid ) ) ;
	 COLOR if ( !IsDirectory( ::cHCHPath ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !IsDirectory( ::cHCHPath ), ;
	 						aGet[ GET_HCHPATH ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 						aGet[ GET_HCHPATH ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ) , .t. );
	 UPDATE
   
   
   REDEFINE GET aGet[ GET_HLIBPATH ] VAR ::cHLibPath  ID ID_GETLIBSPATH 		OF oFld:aDialogs[ FLD_HARBOUROPTION ] ;
   BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetDir( "Select Harbour Libs Path", ::Value() ) ),;
	 																	::VarPut( padR( lower( cTemp ), 128 ) ), ), ;
   													aHLibs := GetLibs( ::Value(), oFromProc:aLibH ), ;
   																						oBrwHLib:aArrayData := aHLibs, ;
   																						oBrwHLib:Refresh() ) ;
		COLOR if ( !IsDirectory(::cHLibPath ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
   	VALID ( aHLibs := GetLibs( ::cHLibPath, ::aLibH ), ;
   					oBrwHLib:aArrayData := aHLibs, ;
   					oBrwHLib:Refresh(), ;
   					if ( !IsDirectory(::cHLibPath ), ;
	 							aGet[ GET_HLIBPATH ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 							aGet[ GET_HLIBPATH ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ), .t. ) ;
   	UPDATE
   									
   									
   REDEFINE GET aGet[ GET_HMOREOPT ] VAR ::cHMoreOpt  ID ID_GETMOREOPTION 	OF oFld:aDialogs[ FLD_HARBOUROPTION ] ;
   	BITMAP "label" ACTION( ::VarPut( TextDialog( ::Value() ) ) );
   	UPDATE
 
   	
   REDEFINE BUTTON ID ID_DEFAULT OF oFld:aDialogs[ FLD_HARBOUROPTION ];
   	ACTION( AEval( oBrwHLib:aArrayData,;
   		{|o| cTemp := o:cOptions, if( o:lActivated := ;
   					if( AScan( ::aHDefaultLib, {| uVal, n, o | uVal == cTemp } ) > 0, .t.,.f. ) , ;
   					::AddRemoveLib( ::aLibH, o:cOptions ),) } ),;
   					oBrwHLib:refresh() )
   
   aHLibs := GetLibs( ::cHLibPath, ::aLibH )
   
      
	 REDEFINE XBROWSE oBrwHLib ;
      FIELDS oBrwHLib:aRow:cOptions, ;
      			 oBrwHLib:aRow:lActivated ;
      HEADERS 'Libraries', 'Activated' ;
      COLSIZES 90, 100 ;
      ARRAY aHLibs OF oFld:aDialogs[ FLD_HARBOUROPTION ]

	 oBrwHLib:bClrStd          = { || If( ( oBrwHLib:nArrayAt % 2 ) == 0, { CLR_BLACK, RGB( 224, 236, 255 ) }, { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
   oBrwHLib:bClrSel          = { || If( ( oBrwHLib:nArrayAt % 2 ) == 0, { CLR_BLACK, RGB( 224, 236, 255 ) }, { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
   oBrwHLib:nMarqueeStyle    = MARQSTYLE_HIGHLCELL
   oBrwHLib:nColDividerStyle = LINESTYLE_DARKGRAY
   oBrwHLib:lHScroll := .f.
   oBrwHLib:lRecordSelector = .f.
   oBrwHLib:lAllowColHiding = .f.
   
   oBrwHLib:aCols[ COL_LIBSELECT ]:nEditType = EDIT_GET
	 oBrwHLib:aCols[ COL_LIBSELECT ]:SetCheck( {"on","off"} )
   oBrwHLib:aCols[ COL_LIBSELECT ]:bStrData := {||nil}
   oBrwHLib:aCols[ COL_LIBSELECT ]:nDataBmpAlign := AL_CENTER
   oBrwHLib:aCols[ COL_LIBSELECT ]:nHeadStrAlign := AL_CENTER
	 //oBrwHLib:aCols[ COL_LIBSELECT ]:bEditvalue := { || Space(0) } 
	 oBrwHLib:aCols[ COL_LIBSELECT ]:bOnPostEdit := {|o,x,n| oBrwHLib:aRow:lActivated := !oBrwHLib:aRow:lActivated ,;
	 	::AddRemoveLib( ::aLibH, oBrwHLib:aRow:cOptions ) } 
   oBrwHLib:CreateFromResource( ID_BROWSELIBS ) 
   oBrwHLib:SetColor( 0, RGB( 224, 236, 255 ) )

	 oFld:aDialogs[ FLD_HARBOUROPTION ]:bGotFocus := {|| oDlg:update }


   //---------------------------------------------------
   // XHARBOUR OPTIONS
   //---------------------------------------------------
   REDEFINE SAY ID ID_SAYCOMPILERPATH OF oFld:aDialogs[ FLD_XHARBOUROPTION ]
   REDEFINE SAY ID ID_SAYINCLUDEPATH 	OF oFld:aDialogs[ FLD_XHARBOUROPTION ]
   REDEFINE SAY ID ID_SAYLIBSPATH 		OF oFld:aDialogs[ FLD_XHARBOUROPTION ]
   REDEFINE SAY ID ID_SAYMOREOPTION 	OF oFld:aDialogs[ FLD_XHARBOUROPTION ]
   
   REDEFINE GET aGet[ GET_XHPATH ] VAR ::cXHPath 		ID ID_GETCOMPILERPATH OF oFld:aDialogs[ FLD_XHARBOUROPTION ] ;
   	BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetDir( "Select xHarbour Complier Path", ::Value() ) ),;
	 																::VarPut( padR( LOWER( cTemp ), 128 ) ),),;
	 													eval( aGet[ GET_XHPATH ]:bValid ) ) ;
	 COLOR if ( !IsDirectory(::cxHPath ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !IsDirectory(::cxHPath ), ;
	 						aGet[ GET_XHPATH ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 						aGet[ GET_XHPATH ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ) , .t. );  
	 UPDATE
   
   REDEFINE GET aGet[ GET_XHCHPATH ] VAR ::cXHCHPath 	ID ID_GETINCLUDEPATH 	OF oFld:aDialogs[ FLD_XHARBOUROPTION ] ;
   	BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetDir( "Select xHarbour Include Path", ::Value() ) ),;
	 																::VarPut( padR( LOWER( cTemp ), 128 ) ),),;
	 													eval( aGet[ GET_HCHPATH ]:bValid ) ) ;
	 COLOR if ( !IsDirectory( ::cxHCHPath ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !IsDirectory( ::cxHCHPath ), ;
	 						aGet[ GET_XHCHPATH ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 						aGet[ GET_XHCHPATH ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ) , .t. );
	 UPDATE
   
   REDEFINE GET aGet[ GET_XHLIBPATH ] VAR ::cXHLibPath ID ID_GETLIBSPATH 		OF oFld:aDialogs[ FLD_XHARBOUROPTION ] ;
   BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetDir( "Select xHarbour Libs Path", ::Value() ) ),;
	 																::VarPut( padR( LOWER( cTemp ), 128 ) ), ), ;
   													aXHLibs := GetLibs( ::Value(), oFromProc:aLibXH ), ;
   																						oBrwXHLib:aArrayData := aXHLibs, ;
   																						oBrwXHLib:Refresh() ) ;
	 COLOR if ( !IsDirectory(::cxHLibPath ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;   																						
   VALID ( aXHLibs := GetLibs( ::cXHLibPath, ::aLibXH ), ;
   				 oBrwXHLib:aArrayData := aXHLibs, ;
   				 oBrwXHLib:Refresh(),;   					
   				 if ( !IsDirectory(::cxHLibPath ), ;
	 							aGet[ GET_XHLIBPATH ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 							aGet[ GET_XHLIBPATH ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ), .t. ) ;
   	UPDATE
   									
   									
   REDEFINE GET aGet[ GET_HMOREOPT ] VAR ::cXHMoreOpt  ID ID_GETMOREOPTION 	OF oFld:aDialogs[ FLD_XHARBOUROPTION ] ;
   	BITMAP "label" ACTION( ::VarPut( TextDialog( ::Value() ) ) );
   	UPDATE
   
   aXHLibs := GetLibs( ::cXHLibPath, ::aLibXH )

	 
   REDEFINE BUTTON ID ID_DEFAULT OF oFld:aDialogs[ FLD_XHARBOUROPTION ];
   	ACTION( AEval( oBrwXHLib:aArrayData,;
   		{|o| cTemp := o:cOptions, if( o:lActivated := ;
   					if( AScan( ::aXHDefaultLib, {| uVal, o | uVal == cTemp } ) > 0, .t.,.f. ) , ;
   					::AddRemoveLib( ::aLibXH, o:cOptions ),) } ),;
   					oBrwXHLib:refresh() )


   
	 REDEFINE XBROWSE oBrwXHLib ;
      FIELDS oBrwXHLib:aRow:cOptions, ;
      			 oBrwXHLib:aRow:lActivated ;
      HEADERS 'Libraries', 'Activated' ;
      COLSIZES 90, 100 ;
      ARRAY aXHLibs OF oFld:aDialogs[ FLD_XHARBOUROPTION ]

	 oBrwXHLib:bClrStd          = { || If( ( oBrwXHLib:nArrayAt % 2 ) == 0, { CLR_BLACK, RGB( 224, 236, 255 ) }, { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
   oBrwXHLib:bClrSel          = { || If( ( oBrwXHLib:nArrayAt % 2 ) == 0, { CLR_BLACK, RGB( 224, 236, 255 ) }, { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
   oBrwXHLib:nMarqueeStyle    = MARQSTYLE_HIGHLROW
   oBrwXHLib:nColDividerStyle = LINESTYLE_DARKGRAY
   oBrwXHLib:lHScroll := .f.
   oBrwXHLib:lRecordSelector = .f.
   oBrwXHLib:lAllowColHiding = .f.

	 oBrwXHLib:aCols[ COL_LIBSELECT ]:SetCheck( {"on","off"},{|o,x,n| oBrwXHLib:aRow:lActivated := !oBrwXHLib:aRow:lActivated,;
	 	 																										 ::AddRemoveLib( ::aLibXH, oBrwXHLib:aRow:cOptions ) } )
   oBrwXHLib:aCols[ COL_LIBSELECT ]:bStrData := {||nil}
   oBrwXHLib:aCols[ COL_LIBSELECT ]:nDataBmpAlign := AL_CENTER
   oBrwXHLib:aCols[ COL_LIBSELECT ]:nHeadStrAlign := AL_CENTER

   oBrwXHLib:CreateFromResource( ID_BROWSELIBS ) 
   oBrwXHLib:SetColor( 0, RGB( 224, 236, 255 ) )

		oFld:aDialogs[ FLD_XHARBOUROPTION ]:bGotFocus := {|| oDlg:update }


//----------------------------------------------------------
// LINKER OPTIONS
//----------------------------------------------------------
		
	 aLnkLibs := {}

	 REDEFINE GROUP ID ID_GROUP_ONE OF oFld:aDialogs[ FLD_LINKEROPTION ]
	 REDEFINE GROUP ID ID_GROUP_TWO OF oFld:aDialogs[ FLD_LINKEROPTION ]


   REDEFINE SAY ID ID_SAYCOMPILERC 	OF oFld:aDialogs[ FLD_LINKEROPTION ]
   REDEFINE SAY ID ID_SAYCFLAG 			OF oFld:aDialogs[ FLD_LINKEROPTION ]
   REDEFINE SAY ID ID_SAYLINKERNAME OF oFld:aDialogs[ FLD_LINKEROPTION ]
   REDEFINE SAY ID ID_SAYBUILDFLAG 	OF oFld:aDialogs[ FLD_LINKEROPTION ]
   REDEFINE SAY ID ID_SAYLIBSPATH 	OF oFld:aDialogs[ FLD_LINKEROPTION ]
   REDEFINE SAY ID ID_SAYRESCOMP 		OF oFld:aDialogs[ FLD_LINKEROPTION ]
   


   REDEFINE GET aGet[ GET_COMPILERC ] VAR ::cCompilerC		ID ID_GETCOMPILERC OF oFld:aDialogs[ FLD_LINKEROPTION ] ;
   BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetFile( "*.exe","Compiler C FileName",, ::Value() ) ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ) , ),;
	 													eval( aGet[ GET_COMPILERC ]:bValid ) ) ;
	 COLOR if ( !file(::cCompilerC ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !file(::cCompilerC ), ;
	 							aGet[ GET_COMPILERC ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 					-		aGet[ GET_COMPILERC ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ), oDlg:update(), .t. );
	 UPDATE
   
   REDEFINE GET aGet[ GET_CFLAG ] VAR ::cCFlag  ID ID_GETCFLAG 	OF oFld:aDialogs[ FLD_LINKEROPTION ] ;
   BITMAP "label" ACTION( ::VarPut( TextDialog( ::Value() ) ) );
   UPDATE

   
   REDEFINE GET aGet[ GET_LNKNAME ] VAR ::cLnkName		ID ID_GETLINKERNAME OF oFld:aDialogs[ FLD_LINKEROPTION ] ;
   BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetFile( "*.exe","Select Linker FileName",, ::Value() ) ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ) , ),;
	 													eval( aGet[ GET_LNKNAME ]:bValid ) ) ;
	 COLOR if ( !file(::cLnkName ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !file(::cLnkName ), ;
	 							aGet[ GET_LNKNAME ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 							aGet[ GET_LNKNAME ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ), oDlg:update(), .t. );
	 UPDATE
   
   REDEFINE GET aGet[ GET_LNKFLAGS ] VAR ::cLnkFlags  ID ID_GETBUILDFLAG 	OF oFld:aDialogs[ FLD_LINKEROPTION ] ;
   BITMAP "label" ACTION( ::VarPut( TextDialog( ::Value() ) ) );
   UPDATE
   
   REDEFINE GET aGet[ GET_LNKLIBS ] VAR ::cLnkLibs ID ID_GETLIBSPATH 		OF oFld:aDialogs[ FLD_LINKEROPTION ] ;
   BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetDir( "Select Linker Libs Path", ::value() ) ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ) , ),;
	 													eval( aGet[ GET_LNKLIBS ]:bValid ) ) ;
	 COLOR if ( !IsDirectory(::cLnkLibs ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !IsDirectory(::cLnkLibs ), ;
	 							aGet[ GET_LNKLIBS ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 							aGet[ GET_LNKLIBS ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ), oBrwLnk:refresh(), .t. ) ;
	 UPDATE
   									
   REDEFINE GET aGet[ GET_RESCOMPILER ] VAR ::cResCompiler ID ID_GETRESCOMP 		OF oFld:aDialogs[ FLD_LINKEROPTION ] ;
   BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetFile( "*.exe","Select Resource Compiler FileName",, ::Value() ) ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ) , ),;
	 													eval( aGet[ GET_RESCOMPILER ]:bValid ) ) ;
	 COLOR if ( !file(::cResCompiler ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !file(::cResCompiler ), ;
	 							aGet[ GET_RESCOMPILER ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 							aGet[ GET_RESCOMPILER ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ), .t. ) UPDATE


		REDEFINE RADIO oRadio VAR ::nResType ;
			ID ID_RADIORC, ID_RADIORES, ID_RADIODLL, ID_RADIONONE OF oFld:aDialogs[ FLD_LINKEROPTION ] UPDATE


	aLnkLibs := GetLibsLnk( ::aLnkLibs )
	
	 REDEFINE XBROWSE oBrwLnk ;
      FIELDS oBrwLnk:aRow:cOptions ;
      HEADERS 'Libraries' ;
      COLSIZES 200;
      ARRAY aLnkLibs OF oFld:aDialogs[ FLD_LINKEROPTION ]

	 oBrwLnk:bClrStd          = { || If( ( oBrwLnk:nArrayAt % 2 ) == 0, ;
	 				{ If( !file( trim( ::cLnkLibs ) + "\"+oBrwLnk:aRow:cOptions), CLR_HRED,CLR_BLACK), RGB( 224, 236, 255 ) }, ;
	 				{ If( !file( trim( ::cLnkLibs ) + "\"+oBrwLnk:aRow:cOptions), CLR_HRED,CLR_BLACK), RGB( 189, 211, 253 ) } ) }
	 				
   oBrwLnk:bClrSel          = { || If( ( oBrwLnk:nArrayAt % 2 ) == 0, ;
   				{ If( !file( trim( ::cLnkLibs ) + "\"+oBrwLnk:aRow:cOptions), CLR_HRED,CLR_BLACK), RGB( 224, 236, 255 ) }, ;
   				{ If( !file( trim( ::cLnkLibs ) + "\"+oBrwLnk:aRow:cOptions), CLR_HRED,CLR_BLACK), RGB( 189, 211, 253 ) } ) }
  				
   oBrwLnk:nMarqueeStyle    = MARQSTYLE_HIGHLROW
   oBrwLnk:nColDividerStyle = LINESTYLE_DARKGRAY
   oBrwLnk:lHScroll := .f.
   oBrwLnk:lRecordSelector = .f.
   oBrwLnk:lAllowColHiding = .f.
	

   oBrwLnk:CreateFromResource( ID_BROWSELIBS ) 
   oBrwLnk:SetColor( 0, RGB( 224, 236, 255 ) )

	REDEFINE BUTTON ID ID_BTNADD 		OF oFld:aDialogs[ FLD_LINKEROPTION ] ;
	ACTION( addlnklibs( oBrwLnk, self ) ) ;
	WHEN IsDirectory(::cLnkLibs ) UPDATE
	
	REDEFINE BUTTON ID ID_BTNREMOVE OF oFld:aDialogs[ FLD_LINKEROPTION ] ;
	ACTION( RemoveLibs( oBrwLnk ), oBrwLnk:refresh() ) ;
	WHEN oBrwLnk:aArrayData[ 1 ]:cOptions != "Not Libs Selected" ;
	UPDATE
	
	REDEFINE BUTTON ID ID_DEFAULT 	OF oFld:aDialogs[ FLD_LINKEROPTION ] ;
	ACTION( aLnkLibs:={}, ;
					AEval( ::aDefaultLnkLib, ;
								{| cLib, n | aadd( aLnkLibs, TCompiler():New() ),;
														 aLnkLibs[ n ]:cOptions := cLib } ) ,;
								 oBrwLnk:aArrayData := aLnkLibs,;
								 oBrwLnk:refresh() ) 
												
	oFld:aDialogs[ FLD_LINKEROPTION ]:bGotFocus := {|| oDlg:update }												
	
//----------------------------------------------------------------------------------------
// PROJECT OPTIONS
//----------------------------------------------------------------------------------------

	aOtherLibs := {}

	 REDEFINE GROUP ID ID_GROUP_ONE OF oFld:aDialogs[ FLD_PRJOPTION ]
	 REDEFINE GROUP ID ID_GROUP_TWO OF oFld:aDialogs[ FLD_PRJOPTION ]
	 REDEFINE GROUP ID ID_GROUP_THREE OF oFld:aDialogs[ FLD_PRJOPTION ]


   REDEFINE SAY ID ID_SAYOUTPUT 	OF oFld:aDialogs[ FLD_PRJOPTION ]
   REDEFINE SAY ID ID_SAYSOURCE 	OF oFld:aDialogs[ FLD_PRJOPTION ]
   REDEFINE SAY ID ID_SAYRESOURCE OF oFld:aDialogs[ FLD_PRJOPTION ]
   REDEFINE SAY ID ID_SAYOBJ 			OF oFld:aDialogs[ FLD_PRJOPTION ]
	 REDEFINE SAY ID ID_SAYMAINPRJ	OF oFld:aDialogs[ FLD_PRJOPTION ]


   REDEFINE GET aGet[ GET_MAINPRJ ] VAR ::cPrjMain		ID ID_GETMAINPRJ OF oFld:aDialogs[ FLD_PRJOPTION ] ;
   BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetDir( "Main Folder", ::Value() ) ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ) , ),;
	 													eval( aGet[ GET_MAINPRJ ]:bValid ) ) ;
	 COLOR if ( !IsDirectory(::cPrjMain ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !IsDirectory(::cPrjMain ), ;
	 							aGet[ GET_MAINPRJ ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 							aGet[ GET_MAINPRJ ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ), oDlg:update(), .t. );
	 UPDATE


   REDEFINE GET aGet[ GET_OUTPUT ] VAR ::cPrjOutput		ID ID_GETOUTPUT OF oFld:aDialogs[ FLD_PRJOPTION ] ;
   BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetDir( "Output Folder", ::Value() ) ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ) , ),;
	 													eval( aGet[ GET_OUTPUT ]:bValid ) ) ;
	 COLOR if ( !IsDirectory(::cPrjOutput ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !IsDirectory(::cPrjOutput ), ;
	 							aGet[ GET_OUTPUT ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 							aGet[ GET_OUTPUT ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ), oDlg:update(), .t. );
	 UPDATE
   
   REDEFINE GET aGet[ GET_SOURCE ] VAR ::cPrjSource  ID ID_GETSOURCE 	OF oFld:aDialogs[ FLD_PRJOPTION ] ;
   BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetDir( "Source Folder", ::Value() ) ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ) , ),;
	 													eval( aGet[ GET_SOURCE ]:bValid ) ) ;
	 COLOR if ( !IsDirectory(::cPrjSource ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !IsDirectory(::cPrjSource ), ;
	 							aGet[ GET_SOURCE ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 							aGet[ GET_SOURCE ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ), oDlg:update(), .t. );
	 UPDATE

   
   REDEFINE GET aGet[ GET_RESOURCE ] VAR ::cPrjRes		ID ID_GETRESOURCE OF oFld:aDialogs[ FLD_PRJOPTION ] ;
   BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetDir( "Resources Folder", ::Value() ) ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ) , ),;
	 													eval( aGet[ GET_RESOURCE ]:bValid ) ) ;
	 COLOR if ( !IsDirectory(::cPrjRes ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !IsDirectory(::cPrjRes ), ;
	 							aGet[ GET_RESOURCE ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 							aGet[ GET_RESOURCE ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ), oDlg:update(), .t. );
	 UPDATE
   
   REDEFINE GET aGet[ GET_OBJ ] VAR ::cPrjObj ID ID_GETOBJ	OF oFld:aDialogs[ FLD_PRJOPTION ] ;
   BITMAP "folder" ACTION ( IF( !empty( cTemp := cGetDir( "Object Folder", ::value() ) ),;
	 																::VarPut( padR( lower( cTemp ), 128 ) ) , ),;
	 													eval( aGet[ GET_OBJ ]:bValid ) ) ;
	 COLOR if ( !IsDirectory(::cPrjObj ), CLR_HRED, CLR_BLACK ), oDlg:nClrPane ;
	 VALID ( if ( !IsDirectory(::cPrjObj ), ;
	 							aGet[ GET_OBJ ]:SetColor( CLR_HRED, oDlg:nClrPane ), ;
	 							aGet[ GET_OBJ ]:SetColor( CLR_BLACK, oDlg:nClrPane ) ), oBrwLnk:refresh(), .t. ) ;
	 UPDATE

	 REDEFINE CHECKBOX oChkBox VAR ::lWndStyle ID ID_CHKSTYLE OF oFld:aDialogs[ FLD_PRJOPTION ]
	 


		REDEFINE RADIO oRadio2 VAR ::nCompiler ;
			ID ID_RADIOH, ID_RADIOXH OF oFld:aDialogs[ FLD_PRJOPTION ] UPDATE


	aOtherLibs := GetLibsLnk( ::aOtherLibs )
	
	
	 REDEFINE XBROWSE oBrwOther ;
      FIELDS oBrwOther:aRow:cOptions ;
      HEADERS 'Libraries' ;
      COLSIZES 200;
      ARRAY aOtherLibs OF oFld:aDialogs[ FLD_PRJOPTION ]

	 oBrwOther:bClrStd          = { || If( ( oBrwOther:nArrayAt % 2 ) == 0, { CLR_BLACK, RGB( 224, 236, 255 ) }, { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
   oBrwOther:bClrSel          = { || If( ( oBrwOther:nArrayAt % 2 ) == 0, { CLR_BLACK, RGB( 224, 236, 255 ) }, { CLR_BLACK, RGB( 189, 211, 253 ) } ) }
   				
   oBrwOther:nMarqueeStyle    = MARQSTYLE_HIGHLROW
   oBrwOther:nColDividerStyle = LINESTYLE_DARKGRAY
   oBrwOther:lHScroll := .f.
   oBrwOther:lRecordSelector = .f.
   oBrwOther:lAllowColHiding = .f.
	

   oBrwOther:CreateFromResource( ID_BROWSELIBS ) 
   oBrwOther:SetColor( 0, RGB( 224, 236, 255 ) )

	REDEFINE BUTTON ID ID_BTNEXE OF oFld:aDialogs[ FLD_PRJOPTION ] ;
	ACTION( MakeFolderExe( Self ), oDlg:Update() )


	REDEFINE BUTTON ID ID_BTNADD 		OF oFld:aDialogs[ FLD_PRJOPTION ] ;
	ACTION( AddOtherLibs( oBrwOther ) )
	
	REDEFINE BUTTON ID ID_BTNREMOVE OF oFld:aDialogs[ FLD_PRJOPTION ] ;
	ACTION( RemoveLibs( oBrwOther ), oBrwOther:refresh() ) ;
	WHEN oBrwOther:aArrayData[ 1 ]:cOptions != "Not Libs Selected" ;
	UPDATE
	
												
	oFld:aDialogs[ FLD_PRJOPTION ]:bGotFocus := {|| oDlg:update }
	
													
//END FOLDER DIALOGS

  REDEFINE BUTTON oBtn ID ID_DEFAULT OF oDlg  ;
  ACTION menupop( oBtn, 10, 10, oFld, oBrw, oBrwHLib, oBrwXHLib, oDlg, self ) 

  ACTIVATE DIALOG oDlg CENTERED 

   if oDlg:nResult == ID_OK
   		aeval( oBrw:aArrayData, {|oRow,n| ::aActivated[ n ] := oRow:lActivated } )
   		::aLibH:={}
   		::aLibXH:={}
   		::aLnkLibs:={}
   		::aOtherLibs:={}
   		aeval( oBrwHLib:aArrayData, {|oRow| if( oRow:lActivated, aadd(::aLibH,oRow:cOptions ),) } )
   		aeval( oBrwXHLib:aArrayData, {|oRow| if( oRow:lActivated, aadd(::aLibXH,oRow:cOptions ),) } )
   		aeval( oBrwLnk:aArrayData, {|oRow| aadd(::aLnkLibs,oRow:cOptions ) } )
   		aeval( oBrwOther:aArrayData, {|oRow| aadd(::aOtherLibs,oRow:cOptions ) } )
      ::CompilerSave()
   endif

return nil


//------------------------------------------------------------------------

Procedure MakeFolderExe( oOption )
local lError 		:= .f.
local cError 	:= "Can't make folder(s):"+CRLF
local cMain 	:= lower( trim( oOption:cPrjMain ) ) + "\"
	
	if !msgyesno( "Do you want create folder to MAIN Folder Project" )
		return
	endif
	
		// make output folder
		if !IsDirectory( cMain + "output" )
			if !lMkDir( cMain + "output" )
				cError += cMain + "output" + CRLF
				lError := .t.
			else 
				oOption:cPrjOutput := padR( cMain + "output", 128 )
			endif
		else
			oOption:cPrjOutput := padR( cMain + "output", 128 )
		endif
		
		// make source folder
		if !IsDirectory( cMain + "source" )
			if !lMkDir( cMain + "source" )
				cError += cMain + "source" + CRLF
				lError := .t.
			else 
				oOption:cPrjSource := padR( cMain + "source", 128 )
			endif
		else
			oOption:cPrjSource := padR( cMain + "source", 128 )
		endif

		// make resource folder
		if !IsDirectory( cMain + "res" )
			if !lMkDir( cMain + "res" )
				cError += cMain + "res" + CRLF
				lError := .t.
			else 
				oOption:cPrjRes := padR( cMain + "res", 128 )
			endif
		else
			oOption:cPrjRes := padR( cMain + "res", 128 )
		endif

		// make Obj folder
		if !IsDirectory( cMain + "obj" )
			if !lMkDir( cMain + "obj" )
				cError += cMain + "obj" + CRLF
				lError := .t.
			else 
				oOption:cPrjObj := padR( cMain + "obj", 128 )
			endif
		else
			oOption:cPrjObj := padR( cMain + "obj", 128 )
		endif
		
		if lError
			msgstop( cError )
		endif
		
return

//----------------------------------------------------
	



CLASS TCompiler

   DATA   oObject
   DATA   cOptions
   DATA   cDescription
   DATA		lActivated
   DATA 	uValue
	
   DATA   bValues
   DATA   nEditType
   DATA   bOnRead
   DATA   bOnWrite
   DATA   bEdit

   METHOD New() INLINE Self
   METHOD GetLabel( nIndex ) INLINE If( ! Empty( nIndex ), eval( ::bValues )[ nIndex ], Space( 30 ) )
   METHOD GetIndex( uValue ) INLINE AScan( eval( ::bValues ) , uValue ) 
   METHOD Value( x ) SETGET

ENDCLASS

METHOD Value( x ) CLASS TCompiler

	   if x != nil .and. ValType( ::bOnWrite ) == "B"
	      Eval( ::bOnWrite, Self, x )
	   endif

return If( ValType( ::bOnRead ) == "B", Eval( ::bOnRead, Self ), Space( 30 ) )



//----------------------------------------------------------------------------

function GetLibs( cPath, aLibs )
local oLibs 	:= {}
local aLibsPath
local nLibs, n, nAt
local lActivated := .f.

	cPath := trim( cPath ) 
	cPath += if( right( cPath,1 )== "\", "*.lib","\*.lib" )
	
	nLibs	:= ADir( cPath )

	if nLibs > 0	
		aLibsPath := DIRECTORY( cPath )
		for n = 1 to nLibs
			IF AScan( aLibs, {| uVal | uVal == aLibsPath[ n,1 ] } ) > 0
				lActivated := .t.
			ELSE
				lActivated := .f.
			ENDIF
			aadd( oLibs, TCompiler():New() )
			oLibs[ n ]:cOptions 	:= aLibsPath[ n, 1 ]
			oLibs[ n ]:lActivated := lActivated
		next
	else
		aadd( oLibs, TCompiler():New() )
		oLibs[ 1 ]:cOptions 	:= "No Found"
		oLibs[ 1 ]:lActivated := .f.
	endif 		
	
	
return oLibs

//------------------------------------------------------------

function GetLibsLnk( aLibs )
local oLibs 	:= {}
local nLibs
local n

	nLibs	:= len( aLibs )

	if nLibs > 0	
		for n = 1 to nLibs
			aadd( oLibs, TCompiler():New() )
			oLibs[ n ]:cOptions 	:= aLibs[ n ]
		next
	else
		aadd( oLibs, TCompiler():New() )
		oLibs[ 1 ]:cOptions 	:= "Not Libs Selected"
	endif 		
	
	
return oLibs

//----------------------------------------------------------------


function AddLnkLibs( oBrw, o )
local cTemp, cTemp2
local oTemp
local aTemp

	cTemp 	:= cGetFile( "*.lib","Select lib",, o:cLnkLibs )
	cTemp2 	:= substr( cTemp, len( trim( o:cLnkLibs ) )+2, len( trim( cTemp ) ) )

	IF !EMPTY( cTemp )
		IF !FILE( trim( o:cLnkLibs ) + "\" + cTemp2 )
				msgstop( "   File Not Found"+CRLF+;
								 "Verify Source Folder" )
		ELSE

			IF oBrw:aRow:cOptions == "Not Libs Selected"
				oBrw:aRow:cOptions := LOWER( cTemp2 )
			ELSE
				IF  ( AScan( oBrw:aArrayData, {| oLib | LOWER( oLib:cOptions )== LOWER( cTemp2 ) } ) ) != 0
					msgstop( "   LIB Found"+CRLF+;
									 "Verify Libs list" )
				ELSE
					oTemp := TCompiler():New()
					aTemp := AClone( oBrw:aArrayData )
					oTemp:cOptions := LOWER( cTemp2 )
					aadd( aTemp, oTemp )
					oBrw:aArrayData := aTemp
				ENDIF
			ENDIF 
		ENDIF
	ENDIF
	
	oBrw:Refresh()

return nil

//-----------------------------------------------------

function RemoveLibs( oBrw )
local cTemp, cTemp2
local oTemp
local aTemp
local oLibs := {}

	IF oBrw:aRow:cOptions == "Not Libs Selected"
		RETURN oLibs
	ELSE
		#ifdef __XHARBOUR__
			ADel( oBrw:aArrayData, oBrw:nArrayAt, .t. )
		#else
			ADel( oBrw:aArrayData, oBrw:nArrayAt )
			Asize( oBrw:aArrayData, len( oBrw:aArrayData ) - 1 )
		#endif
		IF len( oBrw:aArrayData ) == 0
			aadd( oLibs, TCompiler():New() )
			oLibs[ 1 ]:cOptions 	:= "Not Libs Selected"
			oBrw:aArrayData := oLibs
		ENDIF
	ENDIF


return nil

//----------------------------------------------------


function AddOtherLibs( oBrw )
local cTemp
local oTemp
local aTemp

	cTemp 	:= cGetFile( "Lib |*.lib|"+;
											 "Obj|*.obj|","Select lib" )
	//cTemp2 	:= substr( cTemp, len( trim( o:cLnkLibs ) )+2, len( trim( cTemp ) ) )

	
	if AScan( oBrw:aArrayData, {| oRow | trim( lower( oRow:cOptions ) ) == trim( lower( cTemp ) ) } ) != 0
		msgstop( "File Found into List" )
		return nil
	endif

	IF oBrw:aRow:cOptions == "Not Libs Selected"
		oBrw:aRow:cOptions := LOWER( cTemp )
	ELSE
		oTemp := TCompiler():New()
		aTemp := AClone( oBrw:aArrayData )
		oTemp:cOptions := LOWER( cTemp )
		aadd( aTemp, oTemp )
		oBrw:aArrayData := aTemp
	ENDIF
	
	oBrw:Refresh()

return nil


//----------------------------------------------------

function menupop( oBtn, nRow, nCol, oFld, oBrw, oBrwHLib, oBrwXHLib, oDlg, o )
   local oPopup
   local aOptionCompiler, aLibs
   
 	 MENU oPopup POPUP
 	 	MENUITEM "All" ACTION( aeval( oPopup:aItems,{|o|Eval( o:bAction ) },2 ),;
 	 												 oFld:SetOption( FLD_COMPILEROPTION ) )
 	 	
 	 	MENUITEM "Compiler" ;
 	 		ACTION( o:DefaultValue()	 ,;
 	 						o:DefaultActivated(),;
  						aOptionCompiler := GetOptions( o ), ;
  						oBrw:aArrayData := aOptionCompiler, ;
  						oFld:SetOption( FLD_COMPILEROPTION ),;
  						oBrw:refresh(),;
  						oDlg:update(),;
  						oBrw:SetFocus()  )
  				 
 	 	MENUITEM "Harbour" ;
 	 		action( o:DefaultHOption(),;
 	 						aLibs := GetLibs( o:cHLibPath, o:aLibH ),;
 	 						oBrwHLib:aArrayData := aLibs ,;
 	 						oFld:SetOption( FLD_HARBOUROPTION ),;
 	 						oBrwHLib:refresh(),;
 	 						oDlg:Update() )
 	 	
 	 	
 	 	MENUITEM "xHarbour" ;
 	 	 	 		action( o:DefaultXHOption(),;
 	 						aLibs := GetLibs( o:cxHLibPath, o:aLibxH ),;
 	 						oBrwXHLib:aArrayData := aLibs ,;
 	 						oFld:SetOption( FLD_XHARBOUROPTION ),;
 	 						oBrwXHLib:refresh(),;
 	 						oDlg:Update() )
 	 						
 	 MENUITEM "Linker" ;
 	 				action( o:DefaultLnkOption(),;
 	 							oFld:SetOption( FLD_LINKEROPTION ),;
 	 							oDlg:Update() )

 	 MENUITEM "Project" ;
 	 				action( o:DefaultPrj(),;
 	 							oFld:SetOption( FLD_PRJOPTION ),;
 	 							oDlg:Update() )


// 	 	MENUITEM "Linker" action( msginfo( "Linker Options" ) )
 	 ENDMENU
 	 
 	 ACTIVATE POPUP oPopup AT nRow,nCol OF oBtn
 	 
return nil
//---------------------------------------



function GetOptions( o )

   local aOptions := {}, n, oOptions, cOptions

	
   if o != nil
   
      for n = 1 to len( o:aOptions )
         AAdd( aOptions, oOptions := TCompiler():New() )
         oOptions:oObject   = o

         oOptions:cOptions       	  = o:aOptions[ n ]
         oOptions:cDescription  	  = o:aDescription[ n ]
         oOptions:lActivated 			  = o:aActivated[ n ]
         oOptions:uValue						= o:aValue[ n ]
         
         do case
            case AScan( { o:aOptions[ OPC_CREDIT ],;
            									 o:aOptions[ OPC_MEMVAR	],;	
            									 o:aOptions[ OPC_DEBUG ],;
            									 o:aOptions[ OPC_BUILD ] ,;
            									 o:aOptions[ OPC_PDOM ],;
            									 o:aOptions[ OPC_OJB32 ],;
            									 o:aOptions[ OPC_HPO ],;
            									 o:aOptions[ OPC_JAVA ],;
            									 o:aOptions[ OPC_NOLINES ],;
            									 o:aOptions[ OPC_ONEMODULE ],;
            									 o:aOptions[ OPC_NOIMPLICIT ],;
            									 o:aOptions[ OPC_PPO ],;
            									 o:aOptions[ OPC_QUIET ],;
            									 o:aOptions[ OPC_QUIETNOT ],;
            									 o:aOptions[ OPC_SINTAXONLY ],;
            									 o:aOptions[ OPC_VALIABLEM ],;
            									 o:aOptions[ OPC_SUPPRESSSHOT ] }, {| uVal | uVal == oOptions:cOptions } ) > 0
            									 
                 oOptions:nEditType = 0
                 oOptions:bOnRead   = { | |  "" }
                 oOptions:bOnWrite  = { | oOptions, uValue | "" }
                 
						case oOptions:cOptions == o:aOptions[ OPC_OUTPUTTYPEGEN ]  
                 oOptions:nEditType = EDIT_LISTBOX
                 oOptions:bValues   = { || { "Compact", "Normal", "Verbose", "Generate variable list" } }
                 oOptions:bOnRead   = { | oOptions | oOptions:GetLabel( val( o:aValue[ OPC_OUTPUTTYPEGEN ] ) + 1 ) }
                 oOptions:bOnWrite  = { | oOptions, uValue | o:aValue[ OPC_OUTPUTTYPEGEN ] := alltrim( str( oOptions:GetIndex( uValue ) - 1 ) ) }

						case oOptions:cOptions == o:aOptions[ OPC_OUTPUTTYPE ] 
                 oOptions:nEditType = EDIT_LISTBOX
                 oOptions:bValues   = { || { "Compact", "Normal", "Verbose", "Generate variable list" } }
                 oOptions:bOnRead   = { | oOptions | oOptions:GetLabel( val( o:aValue[ OPC_OUTPUTTYPE ] ) + 1 ) }
                 oOptions:bOnWrite  = { | oOptions, uValue | o:aValue[ OPC_OUTPUTTYPE ] := alltrim( str( oOptions:GetIndex( uValue ) - 1 ) ) }
						
						case oOptions:cOptions == o:aOptions[ OPC_DEFINE ]  
                 oOptions:nEditType = EDIT_GET
                 oOptions:bOnRead   = { | oOptions | padR( o:aValue[ OPC_DEFINE ], 128," " )  }
                 oOptions:bOnWrite  = { | oOptions, uValue | o:aValue[ OPC_DEFINE ] := uValue  }

						case oOptions:cOptions == o:aOptions[ OPC_SEVERITY ]  
                 oOptions:nEditType = EDIT_GET
                 oOptions:bOnRead   = { | oOptions | o:aValue[ OPC_SEVERITY ]  }
                 oOptions:bOnWrite  = { | oOptions, uValue | o:aValue[ OPC_SEVERITY ] := uValue  }

						case oOptions:cOptions == o:aOptions[ OPC_INCLUDE ]  
                 oOptions:nEditType = EDIT_GET_BUTTON
                 oOptions:bOnRead   = { | oOptions | padR( o:aValue[ OPC_INCLUDE ], 128," " )  }
                 oOptions:bOnWrite  = { | oOptions, uValue | o:aValue[ OPC_INCLUDE ] := ;
                 												if( !empty( o:aValue[ OPC_INCLUDE ] ),o:aValue[ OPC_INCLUDE ]+";"+ uValue,uValue) }
								 oOptions:bEdit     = { | c |c := cGetDir( "Select include path",CurDirx() ) }

						case oOptions:cOptions == o:aOptions[ OPC_MODE ]  
                 oOptions:nEditType = EDIT_GET
                 oOptions:bOnRead   = { | oOptions | padR( o:aValue[ OPC_MODE ], 30 )  }
                 oOptions:bOnWrite  = { | oOptions, uValue | o:aValue[ OPC_MODE ] := uValue  }

						case oOptions:cOptions == o:aOptions[ OPC_OBJECTFILE ]  
                 oOptions:nEditType = EDIT_GET_BUTTON
                 oOptions:bOnRead   = { | oOptions | padR( o:aValue[ OPC_OBJECTFILE ], 128 )  }
                 oOptions:bOnWrite  = { | oOptions, uValue | o:aValue[ OPC_OBJECTFILE ] := ;
                 												if( !empty( o:aValue[ OPC_OBJECTFILE ] ),o:aValue[ OPC_OBJECTFILE ]+";"+ uValue,uValue) }
								 oOptions:bEdit     = { | c |c := cGetFile( "*.*", ;
								 																						"Select object file drive and/or path",CurDirx() ) }

						case oOptions:cOptions == o:aOptions[ OPC_COMMANDDEF ]  
                 oOptions:nEditType = EDIT_GET_BUTTON
                 oOptions:bOnRead   = { | oOptions | padR( o:aValue[ OPC_COMMANDDEF ], 128 )  }
                 oOptions:bOnWrite  = { | oOptions, uValue | o:aValue[ OPC_COMMANDDEF ] := ;
                 												if( !empty( o:aValue[ OPC_COMMANDDEF ] ),o:aValue[ OPC_COMMANDDEF ]+";"+ uValue,uValue) }
								 oOptions:bEdit     = { | c |c := cGetFile( "*.*", ;
								 																						"use command def set in <file> (or none)",CurDirx() ) }

						case oOptions:cOptions == o:aOptions[ OPC_WARNINGS ]  
                 oOptions:nEditType = EDIT_LISTBOX
                 oOptions:bValues   = { || { "0", "1", "2", "3" } }
                
                 oOptions:bOnRead   = { | oOptions | oOptions:GetLabel( val( o:aValue[ OPC_WARNINGS ]  ) + 1 ) }
                 oOptions:bOnWrite  = { | oOptions, uValue | o:aValue[ OPC_WARNINGS ] := alltrim( str( oOptions:GetIndex( uValue ) - 1 ) ) }

						case oOptions:cOptions == o:aOptions[ OPC_SYMBOL ]  
                 oOptions:nEditType = EDIT_GET
                 oOptions:bOnRead   = { | oOptions | padR( o:aValue[ OPC_SYMBOL ], 30 )  }
                 oOptions:bOnWrite  = { | oOptions, uValue | o:aValue[ OPC_SYMBOL ] := uValue  }

								               
          endcase
  		next
 		endif
 	
return aOptions


//----------------------------------------------------------------------------//


Static function SetEditType( oBrw )

   local oOptions     := oBrw:aRow
   local nEditType 		:= oOptions:nEditType
   local oCol      		:= oBrw:aCols[ COL_VALUE ]
	 local oColSel			:= oBrw:aCols[ COL_SELECT ]
	 
   oCol:nEditType  := nEditType

   do case
   
      case nEditType == EDIT_GET
           oCol:aEditListTxt   = nil
           oCol:aEditListBound = nil
           
      case nEditType == EDIT_LISTBOX
           oCol:aEditListTxt   = eval( oOptions:bValues )
           oCol:aEditListBound = eval( oOptions:bValues ) // remove this if you want the index, not the string

      case nEditType == EDIT_GET_BUTTON
           oCol:bEditBlock = oOptions:bEdit // whatever is returned by the codeblock, it will be asigned

   endcase

return nil


/************************************************
 valores default daniel
/************************************************

		::aFwhDefault := { padR( "c:\fivewin\ver811\fwh\lib", 128 ),;				//FWH/lib folder
  									 	 padR( "c:\fivewin\ver811\fwh\include", 128 ) }		//FWH/include folder


		::aHDefault := { padR( "c:\fivewin\ver811\harbour\bin", 128 ) ,;			//harbour/bin
										 padR( "c:\fivewin\ver811\harbour\include", 128 ) ,;	//harbour/include
										 padR( "c:\fivewin\ver811\harbour\lib", 128 ) ,;			//harbour/lib
										 space( 128 ) }																				//harbour Flags
										 
		::aHDefaultLib := {"hbrtl.lib",;
												"hbvm.lib",;
												"gtgui.lib",;
												"hblang.lib",;
												"hbmacro.lib",;
												"hbrdd.lib",;
												"rddntx.lib",;
												"rddcdx.lib",;
												"rddfpt.lib",;
												"hbsix.lib",;
												"hbdebug.lib",;
												"hbcommon.lib",;
												"hbpp.lib",;
												"hbcpage.lib",;
												"hbw32.lib"}

		::aXHDefaultLib := {"rtl.lib",;
												"vm.lib",;
												"gtgui.lib",;
												"lang.lib",;
												"macro.lib",;
												"rdd.lib",;
												"dbfntx.lib",;
												"dbfcdx.lib",;
												"dbffpt.lib",;
												"hbix.lib",;
												"debug.lib",;
												"common.lib",;
												"pp.lib",;
												"pcrepos.lib2" }
												
		::aDefaultLnkLib := {"cw32.lib",;
												 "import32.lib",;
												 "psdk\odbc32.lib",;
												 "psdk\msimg32.lib",;
												 "psdk\nddeapi.lib",;
												 "psdk\iphlpapi.lib",;
												 "psdk\rasapi32.lib" }
										

		::axHDefault := { padR( "c:\fivewin\ver811\xharbour\bin", 128 )  ,;			//xharbour/bin
										  padR( "c:\fivewin\ver811\xharbour\include", 128 ) ,;	//xharbour/include
											padR( "c:\fivewin\ver811\xharbour\lib", 128 ) ,;			//xharbour/lib
											space( 128 ) }																				//xharbour Flags
			
		::aLnkDefault := { padR( "c:\borland\bcc55\bin\ilink32.exe", 128 ),;		// linker name
											 padR( "-Gn -aa -Tpe -s", 128 ),;											// linker bulid flags
											 padR( "c:\borland\bcc55\lib", 128 ),;								// Borland Lib
											 padR( "c:\borland\bcc55\bin\brc32.exe", 128 ),;			// Resoure Compiler
											 RESTYPE_RC,;																					// Resoure Type
											 padR( "c:\borland\bcc55\bin\bcc32.exe", 128 ),;			// Compiler C
											 padR( "-O2 -c -M -Ic:\borland\bcc55\include", 128 ) }// Compiler C Flags

		::aPrjDefault := { padR( CurDrive()+":\"+curdir(), 128 ),;	//output Folder
											 padR( CurDrive()+":\"+curdir(), 128 ),;	//source Folder
											 padR( CurDrive()+":\"+curdir(), 128 ),;	//resource folder
											 padR( CurDrive()+":\"+curdir(), 128 ),;	//obj folder
											 .t.,;																		//Windows Style
											 HARBOUR,;																//Compiler
										 	 padR( CurDrive()+":\"+curdir(), 128 ) } //main folder																	

		::aOtherLibs := {}											
*/